<template>
  <button class="hm-button" :class="[`hm-button--${type}`,{
    'is-plain': plain
  },{
    'is-round': round
  },{
    'is-circle': circle
  }]">
    <span><slot></slot></span>
  </button>
</template>

<script>
export default {
  name: 'HmButton',
  // 封装一个组件，会对props做一个约束,props校验
  props: {
    type: {
      type: String, // 数据类型： 字符串
      default: 'default'
    },
    plain: {
      type: Boolean,
      default: false
    },
    round: {
      type: Boolean,
      default: false
    },
    circle: {
      type: Boolean,
      default: false
    }
  },
  created () {
    // console.log(`按钮类型：${this.type}`)
    // this.$slots 可以拿到所有的插槽
    // this.$slots.default 传内容了，就会有一个默认的插槽
  }
}
</script>

<style lang="scss" scoped>
.hm-button {
  display: inline-block;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  background: #fff;
  border: 1px solid #dcdfe6;
  color: #606266;
  -webkit-appearance: none;
  text-align: center;
  box-sizing: border-box;
  outline: none;
  margin: 0;
  transition: 0.1s;
  font-weight: 500;
  // 禁止元素的文字被选中
  -moz-user-select: none;
  -webkit-user-select: none;
  -ms-user-select: none;
  padding: 12px 20px;
  font-size: 14px;
  border-radius: 4px;
  &:hover,
  &:focus {
    color: #409eff;
    border-color: #c6e2ff;
    background-color: #ecf5ff;
  }
}
.hm-button--primary {
  color: #fff;
  border-color: #409eff;
  background-color: #409eff;
  &:hover,
  &:focus {
    color: #fff;
    background: #409eff;
    border-color: #409eff;
  }
}
.hm-button--success {
  color: #fff;
  border-color: #67c23a;
  background-color: #67c23a;
  &:hover,
  &:focus {
    color: #fff;
    background: #67c23a;
    border-color: #67c23a;
  }
}
.hm-button--info {
  color: #fff;
  border-color: #909399;
  background-color: #909399;
  &:hover,
  &:focus {
    color: #fff;
    background: #909399;
    border-color: #909399;
  }
}
.hm-button--warning {
  color: #fff;
  border-color: #e6a23c;
  background-color: #e6a23c;
  &:hover,
  &:focus {
    color: #fff;
    background: #e6a23c;
    border-color: #e6a23c;
  }
}
.hm-button--danger {
  color: #fff;
  border-color: #f56c6c;
  background-color: #f56c6c;
  &:hover,
  &:focus {
    color: #fff;
    background: #f56c6c;
    border-color: #f56c6c;
  }
}

.hm-button--primary.is-plain{
  color: #409eff;
  border-color: #409eff;
  background-color: #ecf5ff;
  &:hover,
  &:focus {
    color: #fff;
    background: #409eff;
    border-color: #409eff;
   }
}
.hm-button--success.is-plain {
  color: #67c23a;
  border-color: #67c23a;
  background-color: #f0f9eb;
  &:hover,
  &:focus {
    color: #fff;
    background: #67c23a;
    border-color: #67c23a;
  }
}
.hm-button--info.is-plain {
  color: #909399;
  border-color: #909399;
  background-color: #f4f4f5;
  &:hover,
  &:focus {
    color: #fff;
    background: #909399;
    border-color: #909399;
  }
}
.hm-button--warning.is-plain {
  color: #e6a23c;
  border-color: #e6a23c;
  background-color: #fdf6ec;
  &:hover,
  &:focus {
    color: #fff;
    background: #e6a23c;
    border-color: #e6a23c;
  }
}
.hm-button--danger.is-plain {
  color: #f56c6c;
  border-color: #f56c6c;
  background-color: #fef0f0;
  &:hover,
  &:focus {
    color: #fff;
    background: #f56c6c;
    border-color: #f56c6c;
  }
}
.hm-button.is-round {
  border-radius: 20px;
  padding: 12px 23px;
}
.hm-button.is-circle {
  border-radius: 50%;
  padding: 12px;
}
.hm-button [class*=hm-icon-]+span {
  margin-left: 5px;
}
</style>
